package cn.edu.sdjzu.xg.eagle;

import cn.edu.sdjzu.xg.eagle.dao.SchoolDaoImpl;
import cn.edu.sdjzu.xg.eagle.factory.DaoFactory;
import cn.edu.sdjzu.xg.eagle.factory.ServiceFactory;
import cn.edu.sdjzu.xg.eagle.service.SchoolServiceImpl;

public class Test {
    public static void main(String[] args) {
        try {
            SchoolDaoImpl dao1 = DaoFactory.getDao(SchoolDaoImpl.class, "SchoolDaoImpl");
            SchoolDaoImpl dao2 = DaoFactory.getDao(SchoolDaoImpl.class, "SchoolDaoImpl");
            System.out.println("dao1 与 dao2 是否为同一实例: " + (dao1 == dao2)); // 应输出 true
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            SchoolServiceImpl service = ServiceFactory.getService(SchoolServiceImpl.class, "SchoolServiceImpl");
            SchoolDaoImpl dao = DaoFactory.getDao(SchoolDaoImpl.class, "SchoolDaoImpl");
            System.out.println("Service 实例: " + service);
            System.out.println("DAO 实例: " + dao);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
